<template>
	<view>
		<Navbar></Navbar>
		<view class="u-p-l-30 u-p-r-30 u-p-t-20">
			<scroll-view scroll-y="true" style="height: 1400rpx;" @scrolltolower="scrolltolower">
				<view class="u-font-30 line_height_15 report_content">
					<rich-text :nodes="content"></rich-text>
					<view style="height: 200rpx;"></view>
				</view>
			</scroll-view>
		</view>
		<Bottom :isReturn="true"  :rightText="rightText" @confirm="confirm"></Bottom> 
		
		<!-- 引导注册弹出层 -->
		<Modal :show="modal.show" :confirmText="modal.confirmText" :modalContent="modal.content"
			:showCancel="modal.showCancel" @cancel="modalCancel" @confirm="modalConfirm"></Modal>
	</view>
</template>

<script>
	import Navbar from '@/components/Navbar.vue'
	import Bottom from '@/components/Bottom.vue'
	import Modal from '@/components/Modal.vue'
	import { getAgreement } from '@/network/api.js'
	import { formatContent, InitScene } from '@/utils/index.js'
	export default{
		components:{
			Navbar,
			Bottom,
			Modal
		},
		data(){
			return{
				content:'',
				rightText: '滑动到底部同意',
				isBottom: false,
				inviteId: '',
				modal: {
					show: false,
					showCancel: true,
					confirmText: '申请',
					content: ''
				},
				scene: ''
			}
		},
		async onLoad(){
			await this.$onLaunched
			this.handleGetAgreement()
		},
		methods:{
			handleGetAgreement(){
				getAgreement({type: 28}).then(res=>{
					this.content = formatContent(res.data.content)
				})
			},
			scrolltolower(val){
				this.isBottom = true
				this.rightText = '同意'
			},
			confirm(){
				if(this.isBottom){
					if(uni.getStorageSync("user_status") == 0){
						/* 未注册用户 */
						this.modal.content = '部分功能需注册解锁，注册后即可体验完整服务'
						this.modal.confirmText = '前往注册'
						this.modal.show = true
					}else{
						uni.navigateTo({
							url: "/teaBureau/teaPartnerForm/teaPartnerForm"
						})
					}
				}
			},
			modalConfirm(){
				this.modal.show = false
				uni.setStorageSync("inviterUrl",`teaBureau/teaAgreement/teaAgreement?scene=${this.scene}`)
				uni.navigateTo({
					url: "/pages/register/register"
				})
			},
			modalCancel(){
				this.modal.show = false
				uni.switchTab({
					url: "/pages/home/home"
				})
			}
		}
	}
</script>

<style>
</style>